<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>{% block title %}金融数据平台{% endblock %}</title>
    <!-- Bootstrap CSS -->
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css"
      rel="stylesheet"
    />
    <!-- Font Awesome 图标 -->
    <link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"
    />
    <!-- 自定义CSS -->
    <link
      rel="stylesheet"
      href="{{ url_for('static', filename='css/style.css') }}"
    />
    {% block styles %}{% endblock %}
  </head>
  <body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
      <div class="container-fluid">
        <a class="navbar-brand" href="{{ url_for('index') }}">
          <i class="fas fa-chart-line me-2"></i>金融数据平台
        </a>
        <button
          class="navbar-toggler"
          type="button"
          data-bs-toggle="collapse"
          data-bs-target="#navbarNav"
        >
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav me-auto">
            <li class="nav-item">
              <a
                class="nav-link {% if request.endpoint == 'index' %}active{% endif %}"
                href="{{ url_for('index') }}"
              >
                <i class="fas fa-home me-1"></i>首页
              </a>
            </li>
            {% if current_user.is_authenticated %}
            <li class="nav-item">
              <a
                class="nav-link {% if request.endpoint == 'dashboard' %}active{% endif %}"
                href="{{ url_for('dashboard') }}"
              >
                <i class="fas fa-tachometer-alt me-1"></i>仪表盘
              </a>
            </li>
            <li class="nav-item">
              <a
                class="nav-link {% if request.endpoint == 'tasks' %}active{% endif %}"
                href="{{ url_for('tasks') }}"
              >
                <i class="fas fa-tasks me-1"></i>任务管理
              </a>
            </li>
            <li class="nav-item">
              <a
                class="nav-link {% if request.endpoint == 'data' %}active{% endif %}"
                href="{{ url_for('data') }}"
              >
                <i class="fas fa-database me-1"></i>数据管理
              </a>
            </li>
            {% if current_user.is_admin %}
            <li class="nav-item">
              <a class="nav-link" href="/admin/">
                <i class="fas fa-user-shield me-1"></i>管理后台
              </a>
            </li>
            {% endif %} {% endif %}
          </ul>
          <ul class="navbar-nav">
            {% if current_user.is_authenticated %}
            <li class="nav-item dropdown">
              <a
                class="nav-link dropdown-toggle"
                href="#"
                id="navbarDropdown"
                role="button"
                data-bs-toggle="dropdown"
              >
                <i class="fas fa-user me-1"></i>{{ current_user.username }}
              </a>
              <ul class="dropdown-menu dropdown-menu-end">
                <li>
                  <a class="dropdown-item" href="{{ url_for('logout') }}"
                    >退出登录</a
                  >
                </li>
              </ul>
            </li>
            {% else %}
            <li class="nav-item">
              <a
                class="nav-link {% if request.endpoint == 'login' %}active{% endif %}"
                href="{{ url_for('login') }}"
              >
                <i class="fas fa-sign-in-alt me-1"></i>登录
              </a>
            </li>
            <li class="nav-item">
              <a
                class="nav-link {% if request.endpoint == 'register' %}active{% endif %}"
                href="{{ url_for('register') }}"
              >
                <i class="fas fa-user-plus me-1"></i>注册
              </a>
            </li>
            {% endif %}
          </ul>
        </div>
      </div>
    </nav>

    <!-- 闪现消息 -->
    <div class="container mt-3">
      {% with messages = get_flashed_messages(with_categories=true) %} {% if
      messages %} {% for category, message in messages %}
      <div
        class="alert alert-{{ category }} alert-dismissible fade show"
        role="alert"
      >
        {{ message }}
        <button
          type="button"
          class="btn-close"
          data-bs-dismiss="alert"
          aria-label="Close"
        ></button>
      </div>
      {% endfor %} {% endif %} {% endwith %}
    </div>

    <!-- 主要内容 -->
    <main class="container mt-4">{% block content %}{% endblock %}</main>

    <!-- 页脚 -->
    <footer class="footer bg-light mt-5 py-3">
      <div class="container text-center">
        <span class="text-muted"
          >© 2025 金融数据平台 -
          基于akshare、pandas、pandas_ta和PostgreSQL</span
        >
      </div>
    </footer>

    <!-- Bootstrap JS -->
    <script
      modules="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"
    ></script>
    <!-- 自定义JS -->
    <script modules="{{ url_for('static', filename='js/main.js') }}"></script>
    {% block scripts %}{% endblock %}
  </body>
</html>
